package com.qingzhuge.exception;

import com.qingzhuge.common.HttpCode;

import java.util.Map;

/**
 * @author : zero.xiao
 * @description : 基础
 * @modified :
 */
public abstract class BaseException extends RuntimeException {
    private static final long serialVersionUID = 3055572939773845146L;
    /**传递数据*/
    private Map<String,Object> data;
    static int CODE_VAL = HttpCode.INTERNAL_SERVER_ERROR.value();
    private int code = CODE_VAL;

    public BaseException() {
        super(HttpCode.INTERNAL_SERVER_ERROR.message());
    }

    public BaseException(Map<String,Object> data) {
        this.data = data;
    }

    public BaseException(Throwable ex) {
        super(ex);
    }

    public BaseException(String message) {
        super(message);
    }

    public BaseException(String message, int code) {
        super(message);
        this.code = code;
    }

    public BaseException(String message, Throwable ex) {
        super(message, ex);
    }

    public BaseException(String message, Map<String, Object> data, int code) {
        super(message);
        this.data = data;
        this.code = code;
    }

    /**
     * 错误编码
     *
     * @return HttpCode
     */
    public int getCode() {
        return this.code;
    }

    public void setcode(int code){
        this.code = code;
    }

    public Map<String,Object> getData() {
        return data;
    }

    public void setData(Map<String,Object> data) {
        this.data = data;
    }
}
